package com.tencent.wxcloudrun.controller;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.manager.StoreCardManager;
import com.tencent.wxcloudrun.vo.request.card.*;
import com.tencent.wxcloudrun.vo.response.card.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZhaoZiYin
 * @Date 2025/2/20
 * @Description 商家控制器
 */
@Api(tags = "商家卡片控制器")
@Slf4j
@RestController
@Validated
@RequestMapping("/api/store/card")
public class StoreCardController {

    @Resource
    private StoreCardManager storeCardManager;

    @ApiOperation("新增卡片")
    @PostMapping(value = "/add")
    public ApiResponse<StoreCardAddResVo> addCard(@RequestBody @Valid StoreCardAddReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.addCard(reqVo));
    }

    @ApiOperation("删除卡片")
    @PostMapping(value = "/delete")
    public ApiResponse<StoreCardDeleteResVo> deleteCard(@RequestBody @Valid StoreCardDeleteReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.deleteCard(reqVo));
    }

    @ApiOperation("查询卡片列表")
    @PostMapping(value = "/list")
    public ApiResponse<StoreCardListResVo> listCard(@RequestBody @Valid StoreCardListReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.listCard(reqVo));
    }

    @ApiOperation("审批申请卡片")
    @PostMapping(value = "/approveApply")
    public ApiResponse<StoreCardApproveApplyResVo> approveApply(@RequestBody @Valid StoreCardApproveApplyReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.approveApply(reqVo));
    }

    @ApiOperation("查询卡片总数")
    @PostMapping(value = "/queryCount")
    public ApiResponse<StoreCardQueryCountResVo> queryCount(@RequestBody @Valid StoreCardQueryCountReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.queryCount(reqVo));
    }

    @ApiOperation("分页查询用户卡片总数")
    @PostMapping(value = "/queryUserCount")
    public ApiResponse<IPage<StoreCardQueryUserCountResVo>>
        queryUserCount(@RequestBody @Valid StoreCardQueryUserCountReqVo reqVo) {
        return ApiResponse.ok(storeCardManager.queryUserCount(reqVo));
    }



}
